package cate.game.activity.uppool.msg;

import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.activity.uppool.UpPoolFairyActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBUpPool;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "替换掉一个up灵器选项 的 请求")
public class ExchangeUpFairyReq implements MsgInput {
    @NoteField("功能id")
    public int funcId;
    @NoteField("配置id")
    public int tid;
    @NoteField("位置")
    public int pos;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        UpPoolFairyActivity single = cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (single == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        GameResult<UpPoolFairyActivity> result = single.exchangePoolId(tid, pos);
        if (result.ok()) {
            result.data.noticeUpdate();
        } else {
            game.notice.message(cc.getRole(), result.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBUpPool.EXCHANGE_UP_FAIRY_REQ;
    }
}
